/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package se.kth.lwr.jeat.samples.onsitetreatment;

import org.jscience.physics.amount.Amount;
import se.kth.lwr.jeat.core.Activity;
import se.kth.lwr.jeat.core.ActivityCategory;
import se.kth.lwr.jeat.core.AmountDataSource;
import se.kth.lwr.jeat.core.AmountFunction;
import se.kth.lwr.jeat.utils.ProductionSupport;

/** An abstract production class adapted to the special needs of the JEAT
 * sample program where we usually want to produce things on basis of time and 
 * sharing persons.
 * 
 * SimpleProduction delegates all work to a ProductionSupport. The real value of
 * the class is that it provides a set of project specific production functions
 * that will be available for all sub productions without need for redefinitions 
 *
 * @author davidev
 */
public abstract class SimpleProduction {

    private ProductionSupport support;

    /**
     * constructor
     * @param support productionSupport for the product
     */
    public SimpleProduction(ProductionSupport support) {
        this.support=support;
    }
    
    protected ProductionSupport getProductionSupport(){
        return support;
                
    }
    
    /**Creates a production activity and add it to the category 
     * {@link ActivityCategory.PRODUCTION_PHASE} 
     * 
     * @param name activity name
     * @param desc activity description
     * @param volume amount to produce
     * @param duration lifetime of product
     * @param pe number of persons sharing the product
     * @return a production activity
     */

    public Activity getProduction(String name, String desc, Amount volume, AmountDataSource duration, AmountDataSource pe) {
        AmountFunction function = new AmountFunction();
        function.divide(duration);
        function.divide(pe);
        Activity retval=support.getProduction(name, desc, volume, function);
        retval.joinCategory(ActivityCategory.PRODUCTION_PHASE);
        return retval;
    }
    
    /**Creates a production activity and add it to the category 
     * {@link ActivityCategory.PRODUCTION_PHASE}
     * 
     * @param name activity name
     * @param desc activity description
     * @param volume amount to produce
     * @param duration lifetime of product
     * @param pe number of persons sharing the product
     * @return a production activity
     */
    
    public Activity getProduction(String name, String desc, Amount volume, Amount duration, AmountDataSource pe){
        AmountFunction function=new AmountFunction();
        function.divide(pe);
        Activity retval=support.getProduction(name, desc, volume, duration, function);
        retval.joinCategory(ActivityCategory.PRODUCTION_PHASE);
        return retval;
    }
    
    /**Creates a production activity and add it to the category 
     * {@link ActivityCategory.PRODUCTION_PHASE}
     * 
     * @param name name of activity
     * @param desc description of activity
     * @param function an amountfunction that will be multiplier for the created {@link MultiplierActivity}
     * @return a production activity
     */
    
    public Activity getProduction(String name, String desc, AmountFunction function){
        Activity retval=support.getProduction(name, desc, function);
        retval.joinCategory(ActivityCategory.PRODUCTION_PHASE);
        return retval;
    }

}
